package format

import (
	"bytes"
	"fmt"
	"github.com/sirupsen/logrus"
	"strconv"
)

type MyFormatter struct {
}

func (f MyFormatter) Format(entry *logrus.Entry) ([]byte, error) {

	var buf *bytes.Buffer
	if nil == entry.Buffer {
		buf = &bytes.Buffer{}
	} else {
		buf = entry.Buffer
	}

	s := fmt.Sprintf("[%s]  [%s]   [%s] [%s]  %s\n", entry.Time.Format("2006-01-01 15:04:06"), entry.Level, entry.Caller.File+":"+strconv.Itoa(entry.Caller.Line), entry.Caller.Func.Name(), entry.Message)
	buf.WriteString(s)
	return buf.Bytes(), nil
}
